/*
 * PageTests.cpp
 *
 *  Created on: Mar 2, 2011
 *      Author: Craig Wilson
 */

#include "../src/Page.cpp"
#include "../src/PageHistory.cpp"
#include "../inc/URL.h"
#include <string>

	extern URL array[];
	extern string d1,d2,d3,d4;
	extern LinkedList<URL> l1,l2,l3;
	extern Page *p1,*p2,*p3,*p4;
	extern void iniValues();
	extern PageHistory *history;

	int PageTests(){

		iniValues();

		LinkedList<URL> temp1 = p1->getLinks();
		LinkedList<URL> temp2 = p2->getLinks();
		LinkedList<URL> temp3 = p3->getLinks();

		if(temp1.GetSize()!=4 || temp2.GetSize()!=5 || temp3.GetSize()!=3)
			return 1; //Link Lists incorrect
		if (p1->getURL().compare(array[5])!=0 ||p2->getURL().compare(array[6])!=0 ||p3->getURL().compare(array[7])!=0)
			return 2; //Incorrect URL
		if(p1->getDescription().compare(d1)!=0 ||p2->getDescription().compare(d2)!=0 ||p3->getDescription().compare(d3)!=0)
			return 3; //Description Incorrect
		if(p1->compare(*p2)==0 || p3->compare(*p4)!=0 || p4->compare(*p1)==0)
			return 4; //Incorrect compare
		*p1=*p3;
		delete p3;
		if(p1->compare(*p4)!=0)
			return 5; //Problem with opperator = or delete

		return 0;
	}

	int PageHistoryTests(){

		iniValues();

		history->add(*p1);
		history->add(*p2);
		history->add(*p3);
		history->add(*p4);

		if(history->containsURL(array[0]) || !history->containsURL(array[5]))
			return 1;	//Problem with contains

		Page temp(array[6]);
		if(history->getPage(array[6])->compare(temp)!=0)
			return 2; 	//Problem with getPage

		return 0;
	}
